Pass link search path to doctests even if build script gave no links
authorSean Griffin <sean@seantheprogrammer.com>
Thu, 17 Dec 2015 21:14:40 +0000 (14:14 -0700)
committerSean Griffin <sean@seantheprogrammer.com>
Thu, 17 Dec 2015 21:19:58 +0000 (14:19 -0700)
It is entirely possible for a crate to have a build script that is simply
the equivalent to

```rustc
fn main() {
    println!("cargo:rustc-link-search=native=/some/path");
}
```

Without actually giving anything to link (for example, because the code
contains `#[link(name="foo")]`. In this case, we aren't actually passing
`-L` through when running doctests, even though they're passed when
compiling the main crate.

Fixes #1592

src/cargo/ops/cargo_rustc/mod.rs

index d62f8cbf1f717e676c416797106815f814628896..434faa20bad7d172aef1fc1377085d4d539b2312 100644 (file)
@@ -162,7 +162,9 @@ pub fn compile_targets<'a, 'cfg: 'a>(pkg_targets: &'a PackagesToBuild<'a>,
         let any_dylib = output.library_links.iter().any(|l| {
             !l.starts_with("static=") && !l.starts_with("framework=")
         });
-        if !any_dylib { continue }
+        if !any_dylib && !output.library_links.is_empty() {
+            continue
+        }
         for dir in output.library_paths.iter() {
             cx.compilation.native_dirs.insert(pkg.clone(), dir.clone());
         }